home *** CD-ROM | disk | FTP | other *** search
- class SQRT
- feature
-
- create is
- do
- io.putstring("Integer-Wurzel berechnen von: ");
- io.readint;
- io.putstring("Die Wurzel aus ");
- io.putint(io.lastint);
- io.putstring(" ist ");
- io.putint(sqrt(io.lastint));
- io.new_line;
- end;
-
- sqrt(n: integer): integer is
- require n >= 0
- do
- from
- invariant Result^2 <= n
- until (Result+1)^2 > n
- loop
- Result := Result + 1
- end;
- ensure Result^2 <= n and (Result+1)^2 > n
- end;
-
- end
-